const isPro = process.env.NODE_ENV === 'production' // 生产环境
export default function G6Loader(key) {
  return new Promise((resolve, reject) => {
    if (window.G6) {
      resolve(window.G6)
    } else {
      var script = document.createElement('script')
      script.type = 'text/javascript'
      script.async = false
      script.src = isPro ? '/admin/js/g6.min.js' : '/js/g6.min.js'
      script.onerror = reject
      document.head.appendChild(script)
      script.onload = () => {
        resolve(window.G6)
      }
    }
    window.initG6 = () => {
      resolve(window.G6)
    }
  })
}
